package org.sasha.roulette;

import javax.inject.Inject;

import org.sasha.roulette.event.SessionChangedEvent;
import org.sasha.roulette.event.SpinRegisteredEvent;

import com.github.peholmst.mvp4vaadin.Presenter;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;

@SuppressWarnings("serial")
public class RoulettePresenter extends Presenter<RouletteView> {

    private final EventBus eventBus;

    @Subscribe
    public void onSessionChanged(SessionChangedEvent event) {
        getView().refresh();   
    }
    
    @Subscribe
    public void onSpinRegistered(SpinRegisteredEvent event) {
        getView().onSpinRegistered(event.getSpin());
    }
    
    @Inject
    public RoulettePresenter(final EventBus eventBus) {
        super();
        this.eventBus = eventBus;
        this.eventBus.register(this);
    }
    
}
